import { reqGetAllMajor } from "@/api/reqMajor";
import { reqGetAllSchool } from "@/api/reqSchool";
import { useClassStore } from "@/store/useClassStore";
import { useUsersStore } from "@/store/useUsersStore";
import { type Major } from "@/types/major";
import { type School } from "@/types/school";
import { storeToRefs } from "pinia";
import { ref } from "vue";

export const allBaseList = () => {
  const directionList = ["web前端", "JAVA", "C/C++", "鸿蒙", "少儿编程"];

  const gradeList = ["大一", "大二", "大三", "大四", "研一", "研二"];
  const educationalLevelList = ["专科", "本科", "硕士", "其他"];

  const majorList = ref<Major[]>([]);
  const getAllMajor = async () => {
    const { data } = await reqGetAllMajor();
    majorList.value = data;
  };
  getAllMajor();
  const schoolList = ref<School[]>([]);
  const getAllSchool = async () => {
    const { data } = await reqGetAllSchool();
    schoolList.value = data;
  };
  getAllSchool();
  const usersStore = useUsersStore();
  const { tearchList, manageList } = storeToRefs(usersStore);
  const { getAllUser } = useUsersStore();
  const { classList } = storeToRefs(useClassStore());
  const { getAllClass } = useClassStore();
  //这样写的话，每次进入这个页面，都会重新获取一次最新的班级列表和用户列表
  getAllClass();
  getAllUser();

  return {
    directionList,
    tearchList,
    manageList,
    classList,
    gradeList,
    educationalLevelList,
    schoolList,
    majorList,
  };
};
